package controller;

import java.io.File;

import observerNotification.ObserverNotification;


/**
 * Sets basic results of state methods. state methods are used by the controller to know if an action is do-able or not.
 * 
 * <p>
 * <ul>
 * <li>Project: 	ChatSystemG3</li>
 * <li>Called by: 	controller.*</li>
 * </ul>
 * </p>
 * 
 * @author COMBES Nicolas - LECHANTRE Arnaud
 */
public abstract class State {
	
	/**
	 * performConnect
	 * @param login: login that the user choose. 
	 * @return if the user is already connected, returns null; 
	 *  		else return a changingStateObserverNotification to inform the rest of the application of the new state
	 */
	public ObserverNotification performConnect(String login) {
		return null;
	}
	
	/**
	 * performDisconnect
	 * @return if the user is already disconnected, returns null; 
	 * 		   if he is connected and sending a file, return a questionObserverNotification to ensure he want to disconnect; 
	 * 		   else return a changingStateObserverNotification
	 */
	public ObserverNotification performDisconnect() {
		return null;
	}
	
	/**
	 * sendMessage
	 * @param convId : id of the concerned conv
	 * @param message: message to send
	 * @return null if the state do not enable to send a file (means the state do not extend connectedState); 
	 *         false if the state enable to send a file and the message is empty; 
	 *         true if the state enable to send a file and the message is not empty
	 */
	public Boolean sendMessage(int convId, String message) {
		return null;
	}
	
	/**
	 * sendFile 
	 * @param file : file to send
	 * @return null if the state do not ennable to send a file (means do not extends connected state); 
	 * 		   true if the state enable to send a file (means extends connected state)
	 */
	public Boolean sendFile(File file) {
		return null;
	}                 	

	/**
	 * openConversation
	 * @param userlist: array containing the name of the users that should be added to the discussion
	 * @return true if the userlist is not empty; false otherwise
	 */
	public Boolean openConversation(Object[] userList) {
		return null;
	}
	
	/**
	 * closeConversation
	 * @param convId: unique identifier of the conversation to close
	 * @return null if the state of the user do not enable him to close a conversation (not connected)
	 * 			true if the state of the user enable him to do so
	 */
	public Boolean closeConversation(int convID) {
		return null;
	}

	
	/**
	 * answerFileRequest
	 * @param convId : identifier of the conversation where the file request is being performed
	 * @param accept : answer of the local user
	 * @param filename : name of the file to be transfered
	 * @param donwloadLing : link where the local user choosed to save the file
	 * 
	 * @return : null if the state do not ennable to send a file (means do not extends connected state)
	 * 		     true if the state enable to send a file (means extends connected state)
	 * 			 false if ther is too many file transfer being performed (and we are connected)
	 */
	public Boolean answerFileRequest(int convId, boolean accept, String filename, File donwladLink) {
		return null;
	}

	/**
	 * shareNewFile
	 * 
	 * @return -2 if the state do not ennable to send a file (means do not extends connected state)
	 * 		    otherwise the number of active file transfer after this call
	 * 			-1 if there is the number of transfer limit is reached
	 */
	public int shareNewFile() {
		return -2;
	}
	
	/**
	 * transferFinished
	 * 
	 * Action : decrement the number of running file transfert
	 * 
	 * @return the new number of file transfert.
	 */
	public int transferFinished() {
		return -1;
		
	}
	
	/*--------------------------------------------
	 *            DEPRECATED FUNCTIONS
	 *-------------------------------------------*/
	
	/**
	 * addUser
	 * @param name of the user that should be added
	 * @return default return of each states so return null
	 * @deprecated
	 */
	public Boolean addUser(String name) {
		return null;
	}
	
	/**
	 * processDatagram
	 * @param datagram: Datagram received by the NI interface
	 * @return null if the user is not connected
	 * 		
	 * @deprecated	
	 */
	public Boolean processDatagram(String datagram) {
		return null;
	}
}
